import request from '../utils/request'
/**
 * 添加角色
 */
export const roleAdd = (data: any) => {
  return request({
    url: '/role/add',
    method: 'POST',
    data
  })
}
/**
 * 编辑角色
 */
export const roleEdit = (data: any) => {
  return request({
    url: '/role/edit',
    method: 'POST',
    data
  })
}
/**
 * 获取角色列表
 */
export const roleList = (data?: any) => {
  return request({
    url: '/role/list',
    data
  })
}
/**
 * 获取角色详情
 */
export const roleDetail = (id: string) => {
  return request({
    url: `/role/detail/${id}`
  })
}
/**
 * 删除角色
 */
export const roleDelete = (id: any) => {
  return request({
    url: `/role/delete/${id}`
  })
}
/**
 * 获取指定用户的权限
 */
export const rolePermission = (id: string) => {
  return request({
    url: `/role/resource/${id}`
  })
}
/**
 * 为用户分配角色
 */
export const updateResource = (id: string, data: any) => {
  return request({
    url: `/role/change-resource/${id}`,
    method: 'POST',
    data
  })
}
